function recursivelyComputeAll(directory)
    framesYUV = dir([directory, '/No Tamper/Frames/*.yuv']);
    framesPNG = dir([directory, '/No Tamper/Frames/*.png']);
    framesJPG = dir([directory, '/No Tamper/Frames/*.jpg']);
    % Se non ho immagini eseguo la funzione per le sottocartelle
    if size(framesYUV,1)==0 && size(framesPNG,1)==0 && size(framesJPG,1)==0
        SubDir = dir( directory );
        if size(SubDir,1) > 2
            for ii = 3:size(SubDir,1)
                directory1 = [directory '\' SubDir(ii).name];
                recursivelyComputeAll(directory1);
            end
        end
    else
        if size(framesYUV,1)~= 0
            FILETYPE = 'yuv';
        elseif size(framesJPG,1)~= 0
            FILETYPE = 'jpg';
        elseif size(framesPNG,1)~= 0
            FILETYPE = 'jpg';
        end
        training_dir = [directory, '\No Tamper\'];
        FRAMESIZE = [768 1024];
        params = defineParams(FILETYPE, FRAMESIZE);
        featureVector = extractFeatureVector(training_dir, params);

        % saving the feature vector matrix
        if ~exist([ training_dir '/Feature Vector'], 'dir')
            mkdir([ training_dir '/Feature Vector'])
        end
        save([ training_dir '/Feature Vector/featureVector.mat' ], 'featureVector')
        
        %% Creation of the map

        map = createMap( featureVector, params );
        [ energyThresholds, lumaThresholds ] = defineThresholds( map, training_dir, params );
        % saving the map
        save([ training_dir '/Feature Vector/map.mat' ], 'map')
        
        %% Creation of an image in order to view the regions extracted by the map
        cmap = jet(max(map(:)-min(map(:))+1)); % colormap in order to view colored regions
        % RGB image derived from the colormap
        red = cmap(:,1);
        green = cmap(:,2);
        blue = cmap(:,3);
        temp=map+1-min(map(:));
        fig(:,:,1)=red(temp);
        fig(:,:,2)=green(temp);
        fig(:,:,3)=blue(temp);
        % saving the image into a png file
        imwrite(fig,jet, [training_dir, '/Feature Vector/map.png']);
        
        %% Tampering Detection
        video_list = dir(directory);
        
        for jj = 3:size(video_list,1)
            tamper_dir = [directory, '\', video_list(jj).name];
            if exist(tamper_dir, 'dir')
                detections = detectTamper( map, energyThresholds, lumaThresholds, tamper_dir, params );
                save([ tamper_dir '\detections.mat' ], 'detections')
                
                % Display energy plots
                energyFig = figure;
                t = 1;
                regions = size(detections,2);
                for ii = 1:regions - 1
                    subplot(regions,3,t)
                    imshow(map == ii)
                    t = t + 1;
                    subplot(regions,3,t)
                    plot(detections(ii + 1).energy)
                    t = t + 1;
                    derivativeEnergy = conv(detections(ii + 1).energy, [-1 1], 'valid');
                    subplot(regions,3,t)
                    plot(derivativeEnergy)
                    t = t + 1;
                end

                subplot(regions, 3, t + 1)
                plot(detections(ii + 1).luma)
                derivativeLuma = conv(detections(1).luma, [-1 1], 'valid');
                subplot(regions, 3, t + 2)
                plot(derivativeLuma)
                
                savefig(energyFig, [tamper_dir '\energyAndDetrending.fig'])
                
                % Display luma plots
                lumaFig = figure;
                t = 1;
                regions = size(detections,2);
                for ii = 1:regions - 1
                    subplot(regions,3,t)
                    imshow(map == ii)
                    t = t + 1;
                    subplot(regions,3,t)
                    plot(detections(ii + 1).luma)
                    t = t + 1;
                    derivativeLuma = conv(detections(ii + 1).luma, [-1 1], 'valid');
                    subplot(regions,3,t)
                    plot(derivativeLuma)
                    t = t + 1;
                end

                subplot(regions, 3, t + 1)
                plot(detections(ii + 1).luma)
                derivativeLuma = conv(detections(1).luma, [-1 1], 'valid');
                subplot(regions, 3, t + 2)
                plot(derivativeLuma)
                
                savefig(lumaFig, [tamper_dir '\lumaAndDetrending.fig'])
            end
        end
        
    end